cmake_minimum_required(VERSION 3.25)
project(proconnect C)

set(CMAKE_C_STANDARD 11)
# 指定生成的可执行文件的输出路径为 bin 目录
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin)

set(CMAKE_MODULE_PATH /home/edward/code/lib/nanopb/extra)
find_package(Nanopb REQUIRED)
include_directories(${NANOPB_INCLUDE_DIRS})

# 开启log.c输出颜色
add_definitions(-DLOG_USE_COLOR)

include_directories(lib/log)
include_directories(src)
include_directories(protobuf)

# 添加 nanopb 必要的 .c 文件
set(NANOPB_SRC_DIRS "lib/nanopb")
set(NANOPB_REQUIRED_SRCS "${NANOPB_SRC_DIRS}/pb_encode.c"
        "${NANOPB_SRC_DIRS}/pb_decode.c"
        "${NANOPB_SRC_DIRS}/pb_common.c")

# terminal
add_executable(proconnect main.c src/utils.c src/terminal.c lib/log/log.c
        protobuf/message.pb.c ${NANOPB_REQUIRED_SRCS})
# target_link_libraries(proconnect protobuf-c jansson)

add_executable(test test/test.c protobuf/message.pb.c ${NANOPB_REQUIRED_SRCS})
target_link_libraries(test ${NANOPB_LIBRARIES})


# run_cluster
add_executable(run_cluster examples/run_cluster.c)